<?php
$imgurl    = $this->getSkinUrl('pms/images/1.jpg');
$formdata  = $this->getFormdata();
$data      = $formdata['form_data'];
$websiteId = $formdata['website_id'];
$temp      = json_decode($data, true);
$baseurl   = $this->baseUrl();
?>
<div style="width: 65%;height: auto;float: left;">
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-edit-form fieldset-legend">模板参数</h4>
            <div class="form-buttons"></div>
        </div>
        <div class="fieldset  ignore-validate" id="coupons_information_fieldset">
            <div class="hor-scroll">
                <div class="hor-scroll">
                    <table cellspacing="0" class="form-list">
                        <tbody>
                        <tr>
                            <td class="label"><label for="banner">A--Banner</label></td>
                            <td class="value">
                                <input type="file" name="image[banner][]" id="banner"/><p class="note" id="note_dash"><span>上传图片宽:1920px;高:730px;</span></p>
                                <input type="checkbox" name="images[banner]" value="1" class="checkbox" id="image_banner_delete">
                                <label for="image_banner_delete">是否删除图片</label>
                                <?php if($temp['image']['banner']):?>
                            <p class="note" id="note_dash"><span><a href="<?php echo $baseurl.$temp['image']['banner']?>" target="_blank">预览已上传图片</a></span></p>
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td class="label"><label for="bgcolor">背景颜色</label></td>
                            <td class="value">
                                <?php if($temp && $temp['bgcolor']): ?>
                                    <input id="bgcolor" name="form_data[bgcolor]" value="<?php echo $temp['bgcolor']; ?>" title="背景颜色" style="width:70px;height:20px;border-right: 20px solid <?php echo "#".$temp['bgcolor']; ?>;line-height: 20px;" class="required-entry input-text"  type="text"/><p class="note" id="note_dash"><span>HEX格式,默认为:d51f49</span></p>
                                <?php else: ?>
                                    <input id="bgcolor" name="form_data[bgcolor]"  title="背景颜色" class="required-entry input-text" style="width:70px;height:20px;border-right: 20px solid #d51f49;line-height: 20px;" type="text" value="d51f49"/><p class="note" id="note_dash"><span>HEX格式</span></p>
                                <?php endif; ?>
                            </td>
                        </tr>

                        <tr>
                            <td class="label"><label for="active_notes">B2--说明文字</label></td>
                            <td class="value">
                                <?php if($temp && $temp['active_notes']):?>
                                    <textarea id="active_notes" name="form_data[active_notes]" class="input-text required-entry" style="width: 274px;height: 40px;"><?php echo $temp['active_notes'];?></textarea>
                                <?php else: ?>
                                    <textarea id="active_notes" name="form_data[active_notes]" class="input-text required-entry"  style="width: 274px;height: 40px;"></textarea>
                                <?php endif; ?>
                            </td>
                        </tr>

                        <tr>
                            <td class="label"><label for="hot">A-1-标题一</label></td>
                            <td class="value">
                                <input type="file" name="image[hot][]" id="hot"/><p class="note" id="note_dash"><span>上传图片宽:1120px;高:140px;</span></p>
                                <input type="checkbox" name="images[hot]" value="1" class="checkbox" id="image_hot_delete">
                                <label for="image_hot_delete">是否删除图片</label>
                                <?php if($temp['image']['hot']):?>
                                    <p class="note" id="note_dash"><span><a href="<?php echo $baseurl.$temp['image']['hot']?>" target="_blank">预览已上传图片</a></span></p>
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td class="label"><label for="D_sku">D1--爆款商品展示SKU</label></td>
                            <td class="value">
                                <input type="button" value="添加商品" data-id="1" onclick="addsku(this)">
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="add_dsku">
                                <ul style="border-top: 1px solid #ccc;border-bottom:1px solid #ccc;">
                                    <?php if($temp && $temp['sku1']):?>
                                        <?php foreach($temp['sku1'] as $sku): ?>
                                            <li>
                                                <input type="hidden" name="form_data[sku1][]" value="<?php echo $sku?>"/><?php echo $this->getproductBysku($sku, $websiteId)[0]['storename'];?>
                                                <span class="del_product" style="float: right;cursor: pointer;color: red;">删除</span>
                                            </li>
                                        <?php endforeach; ?>
                                    <?php else: ?>
                                    <?php endif; ?>
                                </ul>
                            </td>
                        </tr>

                        <tr>
                            <td class="label"><label for="activity01">A-2-标题二</label></td>
                            <td class="value">
                                <input type="file" name="image[activity01][]" id="activity01"/><p class="note" id="note_dash"><span>上传图片宽:1120px;高:140px;</span></p>
                                <input type="checkbox" name="images[activity01]" value="1" class="checkbox" id="image_activity01_delete">
                                <label for="image_activity01_delete">是否删除图片</label>
                                <?php if($temp['image']['activity01']):?>
                                    <p class="note" id="note_dash"><span><a href="<?php echo $baseurl.$temp['image']['activity01']?>" target="_blank">预览已上传图片</a></span></p>
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td class="label"><label for="E_sku">D2--低价商品展示SKU</label></td>
                            <td class="value">
                                <input type="button"  value="添加商品" data-id="2" onclick="addsku(this)"><p class="note" id="note_dash"><span>不选择产品,该区域将隐藏</span></p>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="add_dsku">
                                <ul style="border-top: 1px solid #ccc;border-bottom:1px solid #ccc;">
                                    <?php if($temp && $temp['sku2']):?>
                                        <?php foreach($temp['sku2'] as $sku): ?>
                                            <li>
                                                <input type="hidden" name="form_data[sku2][]" value="<?php echo $sku?>"/><?php echo $this->getproductBysku($sku, $websiteId)[0]['storename'];?>
                                                <span class="del_product" style="float: right;cursor: pointer;color: red;">删除</span>
                                            </li>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                                </ul>
                            </td>
                        </tr>

                        <tr>
                            <td class="label"><label for="activity02">A-3-标题三</label></td>
                            <td class="value">
                                <input type="file" name="image[activity02][]" id="activity02"/><p class="note" id="note_dash"><span>上传图片宽:1120px;高:140px;</span></p>
                                <input type="checkbox" name="images[activity02]" value="1" class="checkbox" id="image_activity02_delete">
                                <label for="image_activity02_delete">是否删除图片</label>
                                <?php if($temp['image']['activity02']):?>
                                    <p class="note" id="note_dash"><span><a href="<?php echo $baseurl.$temp['image']['activity02']?>" target="_blank">预览已上传图片</a></span></p>
                                <?php endif;?>
                            </td>
                        </tr>
                        <tr>
                            <td class="label"><label for="F_sku">D3--买赠商品展示SKU</label></td>
                            <td class="value">
                                <input type="button"  value="添加商品" data-id="3" onclick="addsku(this)"/><p class="note" id="note_dash"><span>不选择产品,该区域将隐藏</span></p>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="add_dsku">
                                <ul style="border-top: 1px solid #ccc;border-bottom:1px solid #ccc;">
                                    <?php if($temp && $temp['sku3']):?>
                                        <?php foreach($temp['sku3'] as $sku): ?>
                                            <li>
                                                <input type="hidden" name="form_data[sku3][]" value="<?php echo $sku?>"/><?php echo $this->getproductBysku($sku,$websiteId)[0]['storename'];?>
                                                <span class="del_product" style="float: right;cursor: pointer;color: red;">删除</span>
                                            </li>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td class="label"><label for="moreurl">E2--加载更多</label></td>
                            <td class="value">
                                <input type="text" name="form_data[moreurl]" value="<?php echo $temp['moreurl']?$temp['moreurl']:"";?>" class="required-entry input-text" placeholder="请输入完整路径的链接地址"/>
                            </td>
                        </tr>
                        <tr>
                            <td class="label"><label for="defaultimg">重置所有图片为默认状态</label></td>
                            <td class="value">
                                <button id="resetimg" name="resetimg" color="#00dcc6" title="点击重置" type="button" class="resets"><span><span><span>重置图片</span></span></span></button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="addsku" style="display: none"><?php echo $this->getLayout()->createBlock('pms/adminhtml_activity_addsku')->toHtml(); ?></div>

<div id="right" style="width:30%;float: right">
    <img src = "<?php echo $imgurl; ?>" style="width:100%"/>
</div>
<script>
    //colorPick
    var  $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#bgcolor').colpick({
            layout:'hex',
            submit:0,
            colorScheme:'dark',
            onChange:function(hsb,hex,rgb,el,bySetColor) {
                $j(el).css('border-color','#'+hex);
                if(!bySetColor) $j(el).val(hex);
            }
        }).keyup(function(){
            $j(this).colpickSetColor(this.value);
        });
    });

    //reset imgs
    $j("#resetimg").click(function(){
        var flag = confirm("确认要重置所有图片为默认状态？");
        if(flag){
            var html='<input type="hidden" name="defaultimg" value="defaultimg" class="input-text"/>';
            $j("#resetimg").append(html);
            editForm.submit();
        }
    });
</script>
